#include<iostream>
struct TreeNode {
      int val;
      struct TreeNode *left;
      struct TreeNode *right;
 };
 
int TreeSize(struct TreeNode* root,int size)
{
	if (root == NULL)return size;
	size++;
	size=TreeSize(root->left,size);
	size=TreeSize(root->right,size);
	return size;
}
int countNodes0(struct TreeNode* root){
    return TreeSize(root,0);
}
//
int countNodes(struct TreeNode* root){
    return root==NULL?0:countNodes(root->left)+countNodes(root->right)+1;
}